﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Windows.Media;
using System.ComponentModel;

namespace ViCode_LeVi.Data
{
    [DataContract]
    public class StepResult: INotifyPropertyChanged
    {
        [DataMember]
        public StepResultItem Item { get; set; }
        #region Note
        string _Note;
        [DataMember]
        public string Note 
        {
            get { return _Note; }
            set 
            {
                if (_Note != value)
                {
                    _Note = value;
                    SendPropertyChanged("Note");
                }
            }
        }
        #endregion
        #region Is_StepResult_None
        public bool Is_StepResult_None
        {
            get
            {
                return Item.Value == StepResult.StepResultItem_None.Value; 
            }
            set
            {
                if (value == true)
                {
                    Item = StepResultItem_None;
                }
                SendPropertyChanged("Is_StepResult_None");
                SendPropertyChanged("Is_StepResult_Bad");
                SendPropertyChanged("Is_StepResult_Normal");
                SendPropertyChanged("Is_StepResult_Good");
            }
        }
        #endregion
        #region Is_StepResult_Bad
        public bool Is_StepResult_Bad
        {
            get
            {
                return Item.Value == StepResult.StepResultItem_Bad.Value; 
            }
            set
            {
                if (value == true)
                {
                    Item = StepResultItem_Bad;
                }
                SendPropertyChanged("Is_StepResult_None");
                SendPropertyChanged("Is_StepResult_Bad");
                SendPropertyChanged("Is_StepResult_Normal");
                SendPropertyChanged("Is_StepResult_Good");
            }
        }
        #endregion
        #region Is_StepResult_Normal
        public bool Is_StepResult_Normal
        {
            get
            {
                return Item.Value == StepResult.StepResultItem_Normal.Value;
            }
            set
            {
                if (value == true)
                {
                    Item = StepResultItem_Normal;
                }
                SendPropertyChanged("Is_StepResult_None");
                SendPropertyChanged("Is_StepResult_Bad");
                SendPropertyChanged("Is_StepResult_Normal");
                SendPropertyChanged("Is_StepResult_Good");
            }
        }
        #endregion
        #region Is_StepResult_Good
        public bool Is_StepResult_Good
        {
            get
            {
                return Item.Value == StepResult.StepResultItem_Good.Value;
            }
            set
            {
                if (value == true)
                {
                    Item = StepResultItem_Good;
                }
                SendPropertyChanged("Is_StepResult_None");
                SendPropertyChanged("Is_StepResult_Bad");
                SendPropertyChanged("Is_StepResult_Normal");
                SendPropertyChanged("Is_StepResult_Good");
            }
        }
        #endregion

        public static StepResultItem StepResultItem_None = new StepResultItem() { Value = 0, Color = Brushes.White, Description = string.Empty };
        public static StepResultItem StepResultItem_Bad = new StepResultItem() { Value = 1, Color = Brushes.Red, Description = "Not good" };
        public static StepResultItem StepResultItem_Normal = new StepResultItem() { Value = 2, Color = Brushes.Yellow, Description = "Normal" };
        public static StepResultItem StepResultItem_Good = new StepResultItem() { Value = 3, Color = Brushes.Green, Description = "Good" };


        public static StepResult Create_StepResult_None()
        {
            return new StepResult() { Item = StepResultItem_None }; 
        }
        //public static StepResult StepResult_None = new StepResult() { Item = StepResultItem_None };
        //public static StepResult StepResult_Bad = new StepResult() { Item = StepResultItem_Bad};
        //public static StepResult StepResult_Normal = new StepResult() { Item = StepResultItem_Normal};
        //public static StepResult StepResult_Good = new StepResult() { Item = StepResultItem_Good};


        #region INotifyPropertyChanged Members
        public void SendPropertyChanged(string s)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(s));
        }
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }

    [DataContract]
    public class StepResultItem
    {
        public Brush Color { get; set; }
        
        [DataMember]
        public int Value { get; set; }

        [DataMember]
        public string Description { get; set; }
    }
}
